function l = Fermeture_geometrique(theta1,theta2,theta3,x,y,z)

a=4.25*2*pi/360;     % angle alpha en rd
b=5.885*2*pi/360;    % angle bta en rd
rf=0.270;               % rayon sur plate forme fixe
rm=0.195;               % rayon sur plate forme mobile
h=0.350;                % hauteur de rfrence (hauteur lorsque les vrins sont rentrs)

xf=zeros(6,1);
yf=zeros(6,1);
zf=zeros(6,1);
xm=zeros(6,1);
ym=zeros(6,1);
zm=zeros(6,1);
alpha=zeros(6,1);
beta=zeros(6,1);

u=0;
v=0;

% Calcul des angles alpha
for i = 1:6
    if rem(i,2)~=0
        alpha(i)=u*2*pi/3-a;
        beta(i)=u*2*pi/3-b;
        u=u+1;
    else
        alpha(i)=v*2*pi/3+a;
        beta(i)=v*2*pi/3+b;
        v=v+1;
    end
end

alpha=[alpha(2:6);2*pi+alpha(1)];
beta=[beta(2:6);2*pi+beta(1)];
alpha=[alpha(6);alpha(1:5)];

% Coordonnes de OFBi
xf=rf*cos(beta);
yf=rf*sin(beta);
zf=0*cos(beta);

% Coordonnes de OMAi dans le repre RM
xm=rm*cos(alpha);
ym=rm*sin(alpha);

% Coordonnes de OMAi dans le repre RF
xmf=(-sin(theta1)*sin(theta2)*sin(theta3)+cos(theta1)*cos(theta3))*xm-sin(theta1)*cos(theta2)*ym+(sin(theta1)*sin(theta2)*cos(theta3)+cos(theta1)*sin(theta3))*zm;
ymf=(cos(theta1)*sin(theta2)*sin(theta3)+sin(theta1)*cos(theta3))*xm+cos(theta1)*cos(theta2)*ym +(-cos(theta1)*sin(theta2)*cos(theta3)+sin(theta1)*sin(theta3))*zm;
zmf=-(sin(theta3)*cos(theta2))*xm+sin(theta2)*ym+(cos(theta3)*cos(theta2))*zm;

plot3([xf;[xf(1)]],[yf;[yf(1)]],[zf;[zf(1)]]);
xlabel('X');
ylabel('Y');
zlabel('Z');
hold on;
x2=xmf+x;
y2=ymf+y;
z2=zmf+z;
plot3([x2;[x2(1)]],[y2;[y2(1)]],[z2;[z2(1)]]);
hold on;
for i=1:6
    plot3([xf(i) x2(i)],[yf(i) y2(i)],[zf(i) z2(i)]);
    hold on;
end
hold off;

% Coordonnes de BiAi dans le repre RF
xt=xmf+x-xf;
yt=ymf+y-yf;
zt=zmf+z-zf;


% #Normes des longueurs
l=sqrt(xt.^2+yt.^2+zt.^2);
